package model;

import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "VOYAGE_CTM")
public class VoyageCTM {
	private int id;
	private AgenceCTM depart;
	private AgenceCTM arrivee;
	private String datedepart;
	private List<HoraireCTM> horairesctm;

	public VoyageCTM(AgenceCTM depart, AgenceCTM arrivee, String datedepart) {
		super();
		this.depart = depart;
		this.arrivee = arrivee;
		this.datedepart = datedepart;
	}

	public VoyageCTM() {
		super();
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID_VOYAGE_CTM")
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "AGENCE_DEPART")
	public AgenceCTM getDepart() {
		return depart;
	}

	public void setDepart(AgenceCTM depart) {
		this.depart = depart;
	}

	@ManyToOne
	@JoinColumn(name = "AGENCE_ARRIVEE")
	public AgenceCTM getArrivee() {
		return arrivee;
	}

	public void setArrivee(AgenceCTM arrivee) {
		this.arrivee = arrivee;
	}

	@Column(name = "DATEDEPART")
	public String getDatedepart() {
		return datedepart;
	}

	public void setDatedepart(String datedepart) {
		this.datedepart = datedepart;
	}

	@OneToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER, mappedBy = "voyagectm")
	public List<HoraireCTM> getHorairesctm() {
		return horairesctm;
	}

	public void setHorairesctm(List<HoraireCTM> horairesctm) {
		this.horairesctm = horairesctm;
	}

}
